package com.coder520.common.utils;

import javax.xml.crypto.Data;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtils {

    private static Calendar calendar = Calendar.getInstance();

    /**
     * @Author: Lin
     * @param
     * @Description:获得今天为星期几
     * @Date: 17:04 2017/9/14
     */
    public static int getTodayWeek(){

        calendar.setTime(new Date());
        int week = calendar.get(Calendar.DAY_OF_WEEK)-1;
        if(week<0) week=7;
        return week;
    }

    /**
     * @Author: Lin
     * @param startDate 早上打卡时间
     * @param endDate 晚上打卡时间
     * @Description: 得出打卡时间差
     * @Date: 17:00 2017/9/14
     */
    public static int getMinute(Date startDate, Date endDate){

        long startTime = startDate.getTime();
        long endTime = endDate.getTime();
        int minute = (int) (Math.abs((endTime=startTime))/(1000*60));
        return minute;
    }

    /**
     * @Author: Lin
     * @param hour
     * @param minute
     * @Description: 获取当天某个时间
     * @Date: 17:30 2017/9/14
     */
    public static Date getDate(int hour, int minute){

        calendar.set(Calendar.HOUR_OF_DAY,hour);
        calendar.set(Calendar.MINUTE,minute);
        return calendar.getTime();
    }

}
